<script type="text/javascript">
    $(document).ready(function() {
        // select 2
        $(".select2").select2();

        $('#pengajuanbarang_hargasatuan').autoNumeric({
            aSep: '.', aDec: ',', vMax: "999999999999999", vMin: "0"
        });

        $('#pengajuanbarang_penyusutan').autoNumeric({
            aSep: '.', aDec: ',', vMax: "99999", vMin: "0"
        });

        $('#pengajuanbarang_qty').autoNumeric({
            aSep: '.', aDec: ',', vMax: "99", vMin: "0"
        });

        // date picker
        $(".tanggal").datepicker({
            target: 'tanggal',
            changeMonth: true,
            changeYear: true,
            showOn: 'both',
            buttonImage: '{$BASEURL}/resource/doc/images/icon/calendar.gif',
            buttonImageOnly: true,
            dateFormat: 'yy-mm-dd'
        });
        
        // get jenis barang
        getJenisBarang($("#kategoribarang_cd").val(),{$result.jenisbarang_cd|default:''});
        function getJenisBarang(kategoribarang,jenisbarang){
	    $.ajax({
                type: 'POST',
                data: 'kategoribarang=' + kategoribarang +'&jenisbarang='+ jenisbarang,
                url: '{$config->site_url("inventarisasi/pengadaan/cari_jenis_barang")}',
                success: function(result) {
                    $('#jenisbarang_cd').html(result);
                    $('#jenisbarang_cd').trigger("change");
                }
            });
	}
        
        // get merk
        getMerk($("#kategoribarang_cd").val(),{$result.merk_cd|default:''});
        function getMerk(kategoribarang,merkcd){
	    $.ajax({
                type: 'POST',
                data: 'kategoribarang=' + kategoribarang +'&merk_cd='+ merkcd,
                url: '{$config->site_url("inventarisasi/pengadaan/cari_merk_barang")}',
                success: function(result) {
                    $('#merk_cd').html(result);
                    $('#merk_cd').trigger("change");
                }
            });
	}

        $('#kategoribarang_cd').change(function() {
            var kategoribarang = $("#kategoribarang_cd").val();
            // ajax group
            $.ajax({
                type: 'POST',
                data: 'kategoribarang=' + kategoribarang,
                url: '{$config->site_url("inventarisasi/pengadaan/get_group_asset_by_kategori")}',
                success: function(result) {
                    $('#gpbarang_cd').val(result);
                }
            });
            // ajax jenis barang
            $.ajax({
                type: 'POST',
                data: 'kategoribarang=' + kategoribarang,
                url: '{$config->site_url("inventarisasi/pengadaan/cari_jenis_barang")}',
                success: function(result) {
                    $('#jenisbarang_cd').html(result);
                }
            });
            // ajax merk
            $.ajax({
                type: 'POST',
                data: 'kategoribarang=' + kategoribarang,
                url: '{$config->site_url("inventarisasi/pengadaan/cari_merk_barang")}',
                success: function(result) {
                    $('#merk_cd').html(result);
                }
            });
        });
    });
</script>
<div class="breadcrum">
    <p>
        <a href="#">Inventarisasi</a>
        <span></span><a href="{$config->site_url('inventarisasi/pengadaan')}">Pengadaan</a>
        <span></span><a href="{$config->site_url('inventarisasi/pengadaan/edit/')}/{$result_info.pengadaan_id}">Pengajuan Barang</a>
        <span></span><a href="{$config->site_url('inventarisasi/pengadaan/pengajuan_barang/')}/{$result_info.pengadaan_id}">{$result_info.pengadaan_nomor|default:''}</a>
        <span></span><small>{$result.pengajuanbarang_nama|default:''}</small> 
    </p>
    <div class="clear"></div>
</div>
<div class="sub-nav-content"> 
    <div class="sub-content">
        <div class="table-info-box">
            <h3>No. Pengadaan - {$result_info.pengadaan_nomor|default:''}</h3>
            <table width="100%" class="table-info">
                <tbody>
                    <tr>
                        <th valign="top">Bagian</th>
                        <td>{$result_info.bagian_name|default:''}</td>
                    </tr>
                    <tr>
                        <th width="20%">Manager</th>
                        <td width="80%">{$result_info.bagian_penanggungjawab|default:''}</td>                        
                    </tr>             
                    <tr>
                        <th>Tanggal </th>
                        <td>{$dtm->get_full_date($result_info.pengadaan_date|default:'')}</td>
                    </tr>
                    <tr>
                        <th>Total </th>
                        <td id="total" style="color: red;"><b>Rp. {$total|number_format:0:",":"."}</b></td>                           
                    </tr>
                    <tr>
                        <th>Keterangan</th>
                        <td>{$result_info.pengadaan_keterangan|default:''}</td>
                    </tr>
                </tbody>
            </table>
        </div>   
        <div class="clear"></div>
        <div class="navigation">           
            <div class="navigation-button">
                <ul>
                    <li><a href="{$config->site_url('inventarisasi/pengadaan/add_barang')}/{$result_info.pengadaan_id|default:''}"><img alt="" src="{$BASEURL}/resource/doc/images/icon/add-icon.png">Tambah Barang</a></li> 
                    <li><a href="{$config->site_url('inventarisasi/pengadaan/pengajuan_barang')}/{$result_info.pengadaan_id|default:''}"><img alt="" src="{$BASEURL}/resource/doc/images/icon/icon.notes.blue.png">Daftar Barang</a></li> 
                </ul>
                <div class="clear"></div>
            </div>
        </div>
        <!-- notification template -->
        {include file="base/templates/notification.html"}
        <!-- end of notification template--> 
        <form action="{$config->site_url('inventarisasi/pengadaan/edit_barang_process')}" method="post"> 
            <input type="hidden" name="pengadaan_id" value="{$result_info.pengadaan_id|default:''}">
            <input type="hidden" name="gpbarang_cd" id="gpbarang_cd" value="{$result.gpbarang_cd|default:''}">
            <input type="hidden" name="pengajuanbarang_id" value="{$result.pengajuanbarang_id|default:''}">
            <input type="hidden" name="pengajuanbarang_barang_kondisi" value="{$result.pengajuanbarang_barang_kondisi|default:''}">
            <input type="hidden" name="pengajuanbarang_status" value="{$result.pengajuanbarang_status|default:''}">
            <table width="100%" class="table-input">
                <table width="100%" class="table-input">
                <tbody>
                    <tr class="headrow">
                        <th colspan="4">Tambah Barang</th>
                    </tr>                   
                    <tr>
                        <td>Nama</td>
                        <td>
                            <input type="text" maxlength="100" size="40" value="{$result.pengajuanbarang_nama|default:''}" name="pengajuanbarang_nama">
                            <small>* wajib diisi</small>
                        </td> 
                        <td width="15%">Ruang</td>
                        <td width="25%">
                            <select name="ruang_cd" id="lokasi_cd" style="width:200px;" class ="select2" >
                                <option value=""></option>
                                {foreach from=$rs_ruang item=data}
                                <option value="{$data.ruang_cd|default:''}" {if {$result.ruang_cd|default:''} eq $data.ruang_cd}selected="selected"{/if}>{$data.ruang_nomor}</option>
                                {/foreach}
                            </select>
                            <small>* wajib diisi</small> 
                        </td>   
                    </tr> 
                    <tr>
                        <td>Harga</td>
                        <td>
                            <input style="text-align: right;font-size:16pt;color: red;font-weight: bold;" type="text" maxlength="30" size="15" id="pengajuanbarang_hargasatuan" value="{$result.pengajuanbarang_hargasatuan|default:''}" name="pengajuanbarang_hargasatuan">
                            <small>* wajib diisi</small>
                        </td>
                        <td>Lokasi Barang</td>
                        <td>
                            <select name="lokasi_cd" id="lokasi_cd" style="width:200px;" class ="select2" >
                                <option value=""></option>
                                {foreach from=$rs_lokasi item=data}
                                <option value="{$data.lokasi_cd|default:''}" {if {$result.lokasi_cd|default:''} eq $data.lokasi_cd}selected="selected"{/if}>{$data.lokasi_cd|default:''} - {$data.lokasi_name}</option>
                                {/foreach}
                            </select>
                            <small>* wajib diisi</small> 
                        </td> 
                    </tr> 
                    <tr>
                        <td width="20%">Jumlah</td>
                        <td width="30%">
                            <input type="text" maxlength="5" size="5" name="pengajuanbarang_qty" id="pengajuanbarang_qty" value="{$result.pengajuanbarang_qty|default:''}">
                            <small>* wajib diisi</small>
                        </td> 
                        <td>Kategori Barang</td>
                        <td>
                            <select name="kategoribarang_cd" id="kategoribarang_cd" class ="select2" style="width:200px;">
                                <option value=""></option>
                                {foreach from=$rs_kategoribarang item=data}
                                <option value="{$data.kategoribarang_cd|default:''}" {if {$result.kategoribarang_cd|default:''} eq $data.kategoribarang_cd}selected="selected"{/if}>{$data.kategoribarang_cd|default:''} - {$data.kategoribarang_name}</option>
                                {/foreach}
                            </select>
                            <small>* wajib diisi</small>
                        </td>               
                    </tr> 
                    <tr>                
                        <td width="20%">Umur Ekonomis(Tahun)</td>
                        <td width="20%">
                            <p> <input type="text" maxlength="4" size="4" value="{$result.pengajuanbarang_penyusutan|default:''}" name="pengajuanbarang_penyusutan" id="pengajuanbarang_penyusutan"><b>Tahun</b> <small>* wajib diisi</small></p> 
                        </td> 
                        <td>Jenis Barang</td>
                        <td>
                            <select name="jenisbarang_cd" id="jenisbarang_cd" style="width:200px;" class ="select2"></select> 
                            <small>* wajib diisi</small>
                        </td>  
                    </tr>  
                    <tr>                                  
                        <td>Barang Susut</td>
                        <td>  
                            <label><input type="radio" name="pengajuanbarang_susut" {if $result.pengajuanbarang_susut|default:'' neq '0'} checked="checked" {/if}value="1">IYA</label>
                            <label><input type="radio" name="pengajuanbarang_susut" {if $result.pengajuanbarang_susut|default:'' eq '0'} checked="checked" {/if} value="0">TIDAK</label>
                        </td>
                        <td>Merk Barang</td>
                        <td>
                            <select name="merk_cd" id="merk_cd" style="width:200px;" class ="select2"></select>
                            <small>* wajib diisi</small>
                        </td>
                    </tr>  
                    <tr>  
                        <td>Generate Nomor Invetaris</td>
                        <td>
                            <label><input type="radio" name="pengajuanbarang_generate_noiventaris" {if $result.pengajuanbarang_generate_noiventaris|default:'' neq '0'} checked="checked" {/if}value="1">IYA</label>
                            <label><input type="radio" name="pengajuanbarang_generate_noiventaris" {if $result.pengajuanbarang_generate_noiventaris|default:'' eq '0'} checked="checked" {/if} value="0">TIDAK</label>
                        </td> 
                        <td>Garansi</td>    
                        <td> 
                            <label><input type="radio" name="pengajuanbarang_garansi" {if $result.pengajuanbarang_garansi|default:'' neq '0'} checked="checked" {/if}value="1">IYA</label>
                            <label><input type="radio" name="pengajuanbarang_garansi" {if $result.pengajuanbarang_garansi|default:'' eq '0'} checked="checked" {/if} value="0">TIDAK</label>
                        </td>  

                    </tr>  
                    <tr>  
                        <td width="20%">Vendor</td>
                        <td width="20%">
                            <select name="vendor_cd" id="vendor_cd" style="width:275px;" class ="select2" >
                                <option value=""></option>
                                {foreach from=$rs_vendor item=data}
                                <option value="{$data.vendor_cd|default:''}" {if {$result.vendor_cd|default:''} eq $data.vendor_cd}selected="selected"{/if}>{$data.vendor_name}</option>
                                {/foreach}
                            </select>
                            <small>* wajib diisi</small> 
                        </td>  
                        <!--
                        <td>Tanggal Beli</td>    
                        <td><input class="tanggal" type="text" size="10" name="barang_tglbeli" value="{$result.barang_tglbeli|default:''}" /></td> 
                        -->
                        <td>Tanggal Garansi</td>    
                        <td><input class="tanggal" type="text" size="10" name="pengajuanbarang_tgl_garansi" value="{$result.pengajuanbarang_tgl_garansi|default:''}" /></td> 
                    </tr>   
                    <tr>                
                        <td>Keterangan</td>    
                        <td colspan="3"> 
                            <textarea name="pengajuanbarang_keterangan"  rows="5" cols="50">{$result.pengajuanbarang_keterangan|default:''}</textarea>   
                        </td>                        
                    </tr>  
                    <tr class="submit-box">
                        <td colspan="4">
                            <input type="submit" class="edit-button" value="Simpan" name="save[insert]">
                            <input type="reset" class="edit-button" value="Reset" name="save[reset]">
                        </td>
                    </tr>
                </tbody>
            </table>
            </table>
        </form> 
    </div>